package com.heima.freemarker.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author itheima
 * @since 2022-07-04
 */
@Controller
public class HelloController {

    @GetMapping("/hello")
    public String hello(Model model) {

        model.addAttribute("name", "itheima");

        HashMap<String, Object> map = new HashMap<>();
        map.put("name", "张三");
        map.put("age", 18);
        model.addAttribute("stu", map);

        HashMap<String, Object> map2 = new HashMap<>();
        map2.put("name", "张三1");
        map2.put("age", 118);

        ArrayList<Map> list = new ArrayList<>();
        list.add(map);
        list.add(map2);


        model.addAttribute("stus", list);

        //视图模板的文件名 view模板文件名
        return "01-basic";
    }

}
